Skip to content

YGNodeFree: mark parent dirty when child is freed#57129

Open
cipolleschi wants to merge 1 commit into
react:mainfrom
cipolleschi:export-D107895988
Open

YGNodeFree: mark parent dirty when child is freed#57129
cipolleschi wants to merge 1 commit into
react:mainfrom
cipolleschi:export-D107895988

Conversation

@cipolleschi

Copy link
Copy Markdown
Contributor

Summary:
fixes react/yoga#1659.

problem: YGNodeFree called owner->removeChild(node) to detach the node from its
parent, but never called owner->markDirtyAndPropagate(). the parent's layout stayed
stale after the free, so a subsequent YGNodeCalculateLayout wouldn't recompute it.
YGNodeRemoveChild has always called markDirtyAndPropagateYGNodeFree was just
missing the same call.

YGNodeFreeRecursive was already correct for its recursive child removals (it calls
YGNodeRemoveChild internally), but the terminal YGNodeFree(root) inherited the bug.

fix: added owner->markDirtyAndPropagate() after node->setOwner(nullptr) in
YGNodeFree.

regression tests: dirty_parent_when_child_freed and dirty_parent_when_subtree_freed_recursive
in YGDirtyMarkingTest.cpp.

bypass-github-export-checks

X-link: react/yoga#1969

Reviewed By: javache

Differential Revision: D107895988

Pulled By: cipolleschi

Summary:
fixes react/yoga#1659.

**problem:** `YGNodeFree` called `owner->removeChild(node)` to detach the node from its
parent, but never called `owner->markDirtyAndPropagate()`. the parent's layout stayed
stale after the free, so a subsequent `YGNodeCalculateLayout` wouldn't recompute it.
`YGNodeRemoveChild` has always called `markDirtyAndPropagate` — `YGNodeFree` was just
missing the same call.

`YGNodeFreeRecursive` was already correct for its recursive child removals (it calls
`YGNodeRemoveChild` internally), but the terminal `YGNodeFree(root)` inherited the bug.

**fix:** added `owner->markDirtyAndPropagate()` after `node->setOwner(nullptr)` in
`YGNodeFree`.

regression tests: `dirty_parent_when_child_freed` and `dirty_parent_when_subtree_freed_recursive`
in `YGDirtyMarkingTest.cpp`.

bypass-github-export-checks

X-link: react/yoga#1969

Reviewed By: javache

Differential Revision: D107895988

Pulled By: cipolleschi
@meta-codesync

meta-codesync Bot commented Jun 9, 2026

Copy link
Copy Markdown

@cipolleschi has exported this pull request. If you are a Meta employee, you can view the originating Diff in D107895988.

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Jun 9, 2026
@facebook-github-tools facebook-github-tools Bot added p: Facebook Partner: Facebook Partner labels Jun 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. meta-exported p: Facebook Partner: Facebook Partner

Projects

None yet

Development

Successfully merging this pull request may close these issues.

YGNodeFree does not mark parent as dirty

2 participants